const routes = [
  {
    path: "/", //默认路径
    redirect: "/index",
  },
  {
    path: "/:pathMatch(.*)*", // 匹配所有路径
    name: "NotFound",
    component: () => import("@/views/not-found/NotFound.vue"),
  },
  {
    path: "/index",
    component: () => import("@/views/home/Home.vue"),
  },
  {
    path: "/center",
    component: () => import("@/views/center/Center.vue"),
  },
  {
    path: "/user-manage/UserAdd",
    component: () => import("@/views/user-manage/UserAdd.vue"),
    requireAuth: true,
  },
  {
    path: "/user-manage/UserList",
    component: () => import("@/views/user-manage/UserList.vue"),
    requireAuth: true,
  },
  {
    path: "/news-manage/NewsAdd",
    component: () => import("@/views/news-manage/NewsAdd.vue"),
  },
  /* 
  :newsId的获取
  import { useRouter, useRoute } from "vue-router";
  方式1：
    const router = useRouter();// 用于获取 全局的路由实例
    router.currentRoute.value.params.newsId
  方式2：
    const route = useRoute();// 用于获取 当前路由的状态
    const newsId = ref(route.params.newsId);
  */
  {
    path: "/news-manage/NewsEdit:newsId",
    component: () => import("@/views/news-manage/NewsAdd.vue"),
  },
  {
    path: "/news-manage/NewsList",
    component: () => import("@/views/news-manage/NewsList.vue"),
  },
  {
    path: "/product-manage/ProductAdd",
    component: () => import("@/views/product-manage/ProductAdd.vue"),
  },
  {
    path: "/product-manage/ProductEdit/:productId",
    component: () => import("@/views/product-manage/ProductAdd.vue"),
  },
  {
    path: "/product-manage/ProductList",
    component: () => import("@/views/product-manage/ProductList.vue"),
  },
];

export default routes;
